Filters::spacelessHtml() Add support for use <script> as link to JS - #196
Closed
janbarasek wants to merge 4 commits into
Closed
Filters::spacelessHtml() Add support for use <script> as link to JS#196janbarasek wants to merge 4 commits into
janbarasek wants to merge 4 commits into
Conversation
dg
reviewed
Sep 9, 2019
| $s = rtrim($s); | ||
| } | ||
| return preg_replace_callback( | ||
| $return = (string) preg_replace_callback( // Other cases |
Author
There was a problem hiding this comment.
Because PhpStorm hint to me new type can be returned in future. For example null in case of error.
dg
reviewed
Sep 9, 2019
| $return = (string) preg_replace_callback( // Other cases | ||
| '#[ \t\r\n]+|<(/)?(textarea|pre|script)(?=\W)#si', | ||
| function ($m) use (&$strip) { | ||
| static function (array $m) use (&$strip): string { |
Author
There was a problem hiding this comment.
PHP does not have to create a new instance every time.
dg
reviewed
Sep 9, 2019
| $s | ||
| ); | ||
| $return = (string) preg_replace_callback( // <script> for include JS file | ||
| '/<script\s*([^>]+?)>(?:\s*)<\/script>/', |
Member
There was a problem hiding this comment.
Will this regexp work with input like <script title="> <\/script>"> ?
Author
There was a problem hiding this comment.
This input is not supported now. I'll try to come up with a better solution.
dg
force-pushed
the
master
branch
3 times, most recently
from
September 18, 2019 14:37
1a297fd to
8fb996f
Compare
dg
force-pushed
the
master
branch
4 times, most recently
from
November 20, 2019 11:58
4d5343b to
6edda93
Compare
dg
force-pushed
the
master
branch
3 times, most recently
from
December 17, 2019 04:36
090695a to
dba2a60
Compare
dg
force-pushed
the
master
branch
10 times, most recently
from
December 23, 2019 00:58
d3ff96d to
47c1926
Compare
dg
force-pushed
the
master
branch
2 times, most recently
from
January 3, 2020 22:38
942f9b1 to
753a2fc
Compare
dg
force-pushed
the
master
branch
4 times, most recently
from
January 28, 2020 17:47
12b410d to
3d14ad7
Compare
dg
force-pushed
the
master
branch
4 times, most recently
from
February 12, 2020 14:28
8f69b66 to
682b403
Compare
dg
force-pushed
the
master
branch
6 times, most recently
from
February 28, 2020 13:11
b340768 to
8af4bf1
Compare
dg
force-pushed
the
master
branch
14 times, most recently
from
March 10, 2020 12:21
c3d3812 to
ca328ce
Compare
dg
force-pushed
the
master
branch
2 times, most recently
from
March 12, 2020 12:35
a9010bd to
55326a1
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In case of
block ygenerate too long code:{block x|strip} Lorem ipsum dolor sit amet, <script src="main.js"></script> consectetur adipiscing elit. {/block} ------ {block y|strip} Lorem ipsum dolor sit amet, <script src="main.js" title="value" ></script> consectetur adipiscing elit. {/block}Old return:
New return:
I think this feature is absolutely safe, because if you have empty
<script>body you can safely replace repeating whitespaces to single whitespace.Real case in real website:
Thanks.